package gm.editor;

import gm.data.HoleColor;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 * Lyuk színének a megjelenítését végző cella alaposztálya.
 *
 * @author imruf84
 */
public class HoleColorCellRenderer extends JLabel implements ListCellRenderer {

    private static final Color HIGHLIGHT_COLOR = new MyMetalTheme().getTextHighlightColor();

    public HoleColorCellRenderer() {
        setOpaque(true);
        setIconTextGap(5);
    }

    @Override
    public Component getListCellRendererComponent(JList jlist, Object value, int i, boolean isSelected, boolean cellHasFocus) {
        HoleColor entry = (HoleColor) value;
        setText(entry.getSymbol() + "");
        setIcon(new ColorIcon(16, 16, entry.getColor()));
        if (isSelected) {
            setBackground(HIGHLIGHT_COLOR);
            setForeground(Color.black);
        } else {
            setBackground(Color.white);
            setForeground(Color.black);
        }

        return this;
    }

}
